/*

Replication Do File for Main Results:

Edgell, Amanda B., Valeriya Mechkova, David Altman, Michael Bernhard, and 
	Staffan Lindberg (2017) "When and where do elections matter? A global test 
	of the democratization by elections hypothesis, 1900-2010" 
	DOI:

Data generated using Stata 14
Varieties of Democracy Dataset, Version 6.2 

*/


use "Edgelletal2017_Replication", clear



********************************************************************************
*			Table 1: Global sample, 1900-2010								   *
********************************************************************************

eststo clear

eststo, ti("1.1 Liberal"): qui xtreg v2x_liberal lelec_zorn zerod ///
	lmadgdpt lmadgdpgr wimross_loilpc fe_etfra i.hist_period, robust
eststo, ti("1.2 Deliberative"): qui xtreg v2xdl_delib lelec_zorn zerod ///
	lmadgdpt lmadgdpgr wimross_loilpc fe_etfra i.hist_period, robust
eststo, ti("1.3 Egalitarian"): qui xtreg v2x_egal lelec_zorn zerod ///
	lmadgdpt lmadgdpgr wimross_loilpc fe_etfra i.hist_period, robust

	
estout _all, ///
	cells(b(star fmt(2)) se(par)) ///
	stats(r2_w r2_b r2_o N_clust N, labels(R2-within R2-between R2-overall ///
	Countries Observations)) ///
	starlevels(^ 0.10 * 0.05 ** 0.01 *** 0.001) label varlabel(_cons "Constant") nobaselevels ///
	legend ti("Table 1: Global sample, 1900-2010")


********************************************************************************
*		Table 2: Historical time period samples							  	   *
********************************************************************************
eststo clear

*Early 20th century (1900-1945)
eststo, title ("2.1 Liberal"): qui xtreg v2x_liberal ///
	lelec_zorn zerod lmadgdpt lmadgdpgr wimross_loilpc fe_etfra  ///
	if hist_period==1,  robust
eststo, title ("2.2 Deliberative"): qui xtreg v2xdl_delib ///
	lelec_zorn zerod lmadgdpt lmadgdpgr wimross_loilpc fe_etfra  ///
	if hist_period==1,  robust
eststo, title ("2.3 Egalitarian"): qui xtreg v2x_egal ///
	lelec_zorn zerod lmadgdpt lmadgdpgr wimross_loilpc fe_etfra  ///
	if hist_period==1,  robust

*Cold War (1946-1988)
eststo, title ("2.4 Liberal"): qui xtreg v2x_liberal ///
	lelec_zorn zerod lmadgdpt lmadgdpgr wimross_loilpc ethnic_fr  ///
	if (hist_period==2 | hist_period==3), fe robust
eststo, title ("2.5 Deliberative"): qui xtreg v2xdl_delib ///
	lelec_zorn zerod lmadgdpt lmadgdpgr wimross_loilpc ethnic_fr  ///
	if (hist_period==2 | hist_period==3), fe robust
eststo, title ("2.6 Egalitarian"): qui xtreg v2x_egal ///
	lelec_zorn zerod lmadgdpt lmadgdpgr wimross_loilpc ethnic_fr  ///
	if (hist_period==2 | hist_period==3), fe robust
	
*Third wave (1974-2010)	
eststo, title ("2.7 Liberal"): qui xtreg v2x_liberal ///
	lelec_zorn zerod lmadgdpt lmadgdpgr wimross_loilpc ethnic_fr ae_dacgdp ///
	ae_fdigdp if year>=1974, fe robust
eststo, title ("2.8 Deliberative"): qui xtreg v2xdl_delib ///
	lelec_zorn zerod lmadgdpt lmadgdpgr wimross_loilpc ethnic_fr ae_dacgdp ///
	ae_fdigdp if year>=1974, fe robust
eststo, title ("2.9 Egalitarian"): qui xtreg v2x_egal ///
	lelec_zorn zerod lmadgdpt lmadgdpgr wimross_loilpc ethnic_fr ae_dacgdp ///
	ae_fdigdp if year>=1974, fe robust

estout _all, ///
	cells(b(star fmt(2)) se(par)) ///
	stats(r2_w r2_b r2_o N_clust N, labels(R2-within R2-between R2-overall ///
	Countries Observations)) varlabel(_cons "Constant") ///
	starlevels(^ 0.10 * 0.05 ** 0.01 *** 0.001) label ///
	legend mgroup("Early 20th century (1900-1945)" "Cold War (1946-1988)" ///
	"Third wave (1974-2010)", pattern(1 0 0 1 0 0 1 0 0) span)
	
********************************************************************************
*								Table 3									   *
********************************************************************************

eststo clear

* sub-Saharan Africa: Full sample (1900-2010)
eststo, title("Liberal"): qui xtreg v2x_liberal ///
	lelec_zorn zerod  lmadgdpt lmadgdpgr wimross_loilpc fe_etfra i.hist_period if ///
	region==1,   robust
eststo, title ("Deliberative"): qui xtreg v2xdl_delib ///
	lelec_zorn zerod  lmadgdpt lmadgdpgr wimross_loilpc fe_etfra i.hist_period if ///
	region==1,   robust
eststo, title ("Egalitarian"): qui xtreg v2x_egal ///
	lelec_zorn zerod  lmadgdpt lmadgdpgr wimross_loilpc fe_etfra i.hist_period if  ///
	region==1,   robust

* sub-Saharan Africa: Third wave (1974-2010)
eststo, title("Liberal"): qui xtreg v2x_liberal ///
	lelec_zorn zerod  lmadgdpt lmadgdpgr wimross_loilpc ethnic_fr  ///
	ae_dacgdp ae_fdigdp if ///
	region==1 & year>=1974, fe  robust
eststo, title ("Deliberative"): qui xtreg v2xdl_delib ///
	lelec_zorn zerod  lmadgdpt lmadgdpgr wimross_loilpc ethnic_fr  ///
	ae_dacgdp ae_fdigdp  if ///
	region==1 & year>=1974,  fe robust
eststo, title ("Egalitarian"): qui xtreg v2x_egal ///
	lelec_zorn zerod  lmadgdpt lmadgdpgr wimross_loilpc ethnic_fr  ///
	ae_dacgdp ae_fdigdp  if  ///
	region==1 & year>=1974, fe  robust
	
	
* MENA: Full sample (1900-2010)
eststo, title("Liberal"): qui xtreg v2x_liberal ///
	lelec_zorn zerod  lmadgdpt lmadgdpgr wimross_loilpc fe_etfra i.hist_period if ///
	region==2,   robust
eststo, title ("Deliberative"): qui xtreg v2xdl_delib ///
	lelec_zorn zerod  lmadgdpt lmadgdpgr wimross_loilpc fe_etfra i.hist_period if ///
	region==2,   robust
eststo, title ("Egalitarian"): qui xtreg v2x_egal ///
	lelec_zorn zerod  lmadgdpt lmadgdpgr wimross_loilpc fe_etfra i.hist_period if  ///
	region==2,   robust

* MENA: Third wave (1974-2010)
eststo, title("Liberal"): qui xtreg v2x_liberal ///
	lelec_zorn zerod  lmadgdpt lmadgdpgr wimross_loilpc ethnic_fr  ///
	ae_dacgdp ae_fdigdp if ///
	region==2 & year>=1974,  fe robust
eststo, title ("Deliberative"): qui xtreg v2xdl_delib ///
	lelec_zorn zerod  lmadgdpt lmadgdpgr wimross_loilpc ethnic_fr  ///
	ae_dacgdp ae_fdigdp  if ///
	region==2 & year>=1974,  fe robust
eststo, title ("Egalitarian"): qui xtreg v2x_egal ///
	lelec_zorn zerod  lmadgdpt lmadgdpgr wimross_loilpc ethnic_fr  ///
	ae_dacgdp ae_fdigdp  if  ///
	region==2 & year>=1974, fe  robust
	
	
* LAC: Full sample (1900-2010)
eststo, title("Liberal"): qui xtreg v2x_liberal ///
	lelec_zorn zerod  lmadgdpt lmadgdpgr wimross_loilpc fe_etfra i.hist_period if ///
	region==3,   robust
eststo, title ("Deliberative"): qui xtreg v2xdl_delib ///
	lelec_zorn zerod  lmadgdpt lmadgdpgr wimross_loilpc fe_etfra i.hist_period if ///
	region==3,   robust
eststo, title ("Egalitarian"): qui xtreg v2x_egal ///
	lelec_zorn zerod  lmadgdpt lmadgdpgr wimross_loilpc fe_etfra i.hist_period if  ///
	region==3,   robust

* LAC: Third wave (1974-2010)
eststo, title("Liberal"): qui xtreg v2x_liberal ///
	lelec_zorn zerod  lmadgdpt lmadgdpgr wimross_loilpc ethnic_fr  ///
	ae_dacgdp ae_fdigdp if ///
	region==3 & year>=1974, fe  robust
eststo, title ("Deliberative"): qui xtreg v2xdl_delib ///
	lelec_zorn zerod  lmadgdpt lmadgdpgr wimross_loilpc ethnic_fr  ///
	ae_dacgdp ae_fdigdp  if ///
	region==3 & year>=1974,  fe robust
eststo, title ("Egalitarian"): qui xtreg v2x_egal ///
	lelec_zorn zerod  lmadgdpt lmadgdpgr wimross_loilpc ethnic_fr  ///
	ae_dacgdp ae_fdigdp  if  ///
	region==3 & year>=1974, fe   robust
	
* Asia: Full sample (1900-2010)
eststo, title("Liberal"): qui xtreg v2x_liberal ///
	lelec_zorn zerod  lmadgdpt lmadgdpgr wimross_loilpc fe_etfra i.hist_period if ///
	region==4,   robust
eststo, title ("Deliberative"): qui xtreg v2xdl_delib ///
	lelec_zorn zerod  lmadgdpt lmadgdpgr wimross_loilpc fe_etfra i.hist_period if ///
	region==4,   robust
eststo, title ("Egalitarian"): qui xtreg v2x_egal ///
	lelec_zorn zerod  lmadgdpt lmadgdpgr wimross_loilpc fe_etfra i.hist_period if  ///
	region==4,   robust

* Asia: Third wave (1974-2010)
eststo, title("Liberal"): qui xtreg v2x_liberal ///
	lelec_zorn zerod  lmadgdpt lmadgdpgr wimross_loilpc ethnic_fr  ///
	ae_dacgdp ae_fdigdp if ///
	region==4 & year>=1974, fe  robust
eststo, title ("Deliberative"): qui xtreg v2xdl_delib ///
	lelec_zorn zerod  lmadgdpt lmadgdpgr wimross_loilpc ethnic_fr  ///
	ae_dacgdp ae_fdigdp  if ///
	region==4 & year>=1974, fe  robust
eststo, title ("Egalitarian"): qui xtreg v2x_egal ///
	lelec_zorn zerod  lmadgdpt lmadgdpgr wimross_loilpc ethnic_fr  ///
	ae_dacgdp ae_fdigdp  if  ///
	region==4 & year>=1974, fe  robust
	
	
* PCE: Full sample (1900-2010)
eststo, title("Liberal"): qui xtreg v2x_liberal ///
	lelec_zorn zerod  lmadgdpt lmadgdpgr wimross_loilpc fe_etfra i.hist_period if ///
	region==5,   robust
eststo, title ("Deliberative"): qui xtreg v2xdl_delib ///
	lelec_zorn zerod  lmadgdpt lmadgdpgr wimross_loilpc fe_etfra i.hist_period if ///
	region==5,   robust
eststo, title ("Egalitarian"): qui xtreg v2x_egal ///
	lelec_zorn zerod  lmadgdpt lmadgdpgr wimross_loilpc fe_etfra i.hist_period if  ///
	region==5,   robust

* PCE: Third wave (1974-2010)
eststo, title("Liberal"): qui xtreg v2x_liberal ///
	lelec_zorn zerod  lmadgdpt lmadgdpgr wimross_loilpc ethnic_fr  ///
	ae_dacgdp ae_fdigdp if ///
	region==5 & year>=1974,  fe robust
eststo, title ("Deliberative"): qui xtreg v2xdl_delib ///
	lelec_zorn zerod  lmadgdpt lmadgdpgr wimross_loilpc ethnic_fr  ///
	ae_dacgdp ae_fdigdp  if ///
	region==5 & year>=1974,   fe robust
eststo, title ("Egalitarian"): qui xtreg v2x_egal ///
	lelec_zorn zerod  lmadgdpt lmadgdpgr wimross_loilpc ethnic_fr  ///
	ae_dacgdp ae_fdigdp  if  ///
	region==5 & year>=1974,  fe robust
	
	

estout est1 est2 est3 est4 est5 est6, ///
	cells(b(star fmt(2)) se(par)) ///
	stats(r2_w r2_b r2_o  N_clust N, labels(R2-within R2-between R2-overall ///
	Countries Observations)) ///
	starlevels(^ 0.10 * 0.05 ** 0.01 *** 0.001) label legend ///
	mgroup("Full sample (1900-2010)" "Third wave (1974-2010)", ///
	pattern(1 0 0 1 0 0) span) keep(lelec_zorn zerod) title("sub-Saharan Africa")
	
estout est7 est8 est9 est10 est11 est12, ///
	cells(b(star fmt(2)) se(par)) ///
	stats(r2_w r2_b r2_o  N_clust N, labels(R2-within R2-between R2-overall ///
	Countries Observations)) ///
	starlevels(^ 0.10 * 0.05 ** 0.01 *** 0.001) label legend ///
	mgroup("Full sample (1900-2010)" "Third wave (1974-2010)", ///
	pattern(1 0 0 1 0 0) span) keep(lelec_zorn zerod) title("Middle East and North Africa")
	
estout est13 est14 est15 est16 est17 est18, ///
	cells(b(star fmt(2)) se(par)) ///
	stats(r2_w r2_b r2_o  N_clust N, labels(R2-within R2-between R2-overall ///
	Countries Observations)) ///
	starlevels(^ 0.10 * 0.05 ** 0.01 *** 0.001) label legend ///
	mgroup("Full sample (1900-2010)" "Third wave (1974-2010)", ///
	pattern(1 0 0 1 0 0) span) keep(lelec_zorn zerod) title("Latin America and the Caribbean")
	
estout est19 est20 est21 est22 est23 est24, ///
	cells(b(star fmt(2)) se(par)) ///
	stats(r2_w r2_b r2_o  N_clust N, labels(R2-within R2-between R2-overall ///
	Countries Observations)) ///
	starlevels(^ 0.10 * 0.05 ** 0.01 *** 0.001) label legend ///
	mgroup("Full sample (1900-2010)" "Third wave (1974-2010)", ///
	pattern(1 0 0 1 0 0) span) keep(lelec_zorn zerod) title("Asia")
	
estout est25 est26 est27 est28 est29 est30, ///
	cells(b(star fmt(2)) se(par)) ///
	stats(r2_w r2_b r2_o  N_clust N, labels(R2-within R2-between R2-overall ///
	Countries Observations)) ///
	starlevels(^ 0.10 * 0.05 ** 0.01 *** 0.001) label legend ///
	mgroup("Full sample (1900-2010)" "Third wave (1974-2010)", ///
	pattern(1 0 0 1 0 0) span) keep(lelec_zorn zerod) title("post-communist Eurasia")
	






